package iosr11.data;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.util.Hashtable;

public abstract class Entity {
	private String id;

	public Entity(){
		
	}
	public Entity(String id){
		this.id = id;
	}
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
	

	
	
	public String toString(){
		Hashtable<String,Object> h = new Hashtable<String,Object>();
		   Class cls = this.getClass();
		   Field[] f = cls.getDeclaredFields();
		   AccessibleObject.setAccessible(f, true);
		   for (int i = 0; i < f.length; i++) {
		       try {
		    	   if (f[i]!=null)
		    		   if(f[i].get(this)!=null)
		    			   h.put(f[i].getName(),f[i].get(this));
		       }
		       catch (IllegalAccessException e) {
		          e.printStackTrace();
		       }
		   }
		   return cls.getName() + h;
	}
}
